
import request from "./request";

/**
 *  根据ip获取所在城市的adcode
 * @returns 
 */
export const getAdcodeByIp = () => {
    return request(
        {
            url: "/ip",
            method: "get",
        }
    )
}


/**
 * 根据城市名称获取城市的adcode
 * @param {*} cityName 城市名称
 * @returns 
 */
export const getAdcodeByCityName = (cityName) => {
    return request(
        {
            url: "/geocode/geo",
            method: "get",
            params: {
                address: cityName
            }
        }
    )
}


/**
 * 根据adcode获取城市的天气信息
 * @param {*} adcode 城市的adcode
 * @param {*} extensions 获取预报天气all,当日天气base
 * @returns 
 */
export const getWeatherByAdcode = (adcode,extensions = "all") => {
    return request(
        {
            url: "/weather/weatherInfo",
            method: "get",
            params: {
                city: adcode,
                extensions:extensions
            }
        }
    )
}